package org.sam.swing.table.defaultImpl;

import java.util.Collection;
import java.util.Map;

import org.sam.swing.table.JSTableModel;
import org.sam.swing.table.JSTableModelEvent;
import org.sam.swing.table.JSTableModelLinster;

/**
 * 默认的接口方式实现，主要是为了方便继承扩展用
 * @author sam
 *
 * @param <E>
 */
public interface JSTableModelDefaultLinster<E> extends JSTableModelLinster<Collection<E>> {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void beforeRetrieve(JSTableModelEvent event) throws Exception {
		event.getTableModel().clear();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default Collection<E> onRetrieve() throws Exception {
		return null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void afterRetrieve(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void beforeUpdate(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default boolean update(JSTableModelEvent event) throws Exception {
		return true;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void afterUpdate(JSTableModelEvent event) throws Exception {
		event.getTableModel().resetUpdate();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void beforeDelete(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void afterDelete(JSTableModelEvent event) throws Exception {

	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void beforeAppend(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void afterAppend(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void beforeInsert(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public default void afterInsert(JSTableModelEvent event) throws Exception {
	}

	/**
	 * {@inheritDoc}
	 */
	public default boolean check(JSTableModel<?> tableModel , Map<Integer, String> result){
		return true;
	}
}
